home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / RTF / rtftoken.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  5KB  |  411 lines

  1. /* rtftoken.h
  2.    from:
  3.     rtf.h - RTF document processing stuff.  Distribution 1.06.
  4. */
  5.  
  6. #ifndef __rtftoken_h
  7. #define __rtftoken_h
  8.  
  9. #define EOF (-1)
  10.  
  11. class RTF{
  12. public:
  13. /*
  14.     Twentieths of a point (twips) per inch (Many RTF measurements
  15.     are in twips per inch (tpi) units).  Assumes 72 points/inch.
  16. */
  17.  
  18. enum{    twips=        1440};
  19.  
  20. /*
  21.     Token classes (must be zero-based and sequential)
  22. */
  23.  
  24. enum{
  25. Unknown,
  26. Group,
  27. Text,
  28. Control,
  29. Eof,
  30. MaxClass};
  31.  
  32. /*
  33.     Brace class major numbers
  34. */
  35.  
  36. enum{
  37. BeginGroup,
  38. EndGroup};
  39.  
  40. /*
  41.     Control class major and minor numbers.
  42. */
  43. enum{
  44. Version,
  45. DefFont,
  46. CharSet,
  47. Destination,
  48. FontFamily,
  49. ColorName,
  50. SpecialChar,
  51. StyleAttr,
  52. DocAttr,
  53. SectAttr,
  54. TblAttr,
  55. ParAttr,
  56. CharAttr,
  57. PictAttr,
  58. FieldAttr,
  59. TOCAttr,
  60. PosAttr};
  61.  
  62. enum{
  63. Pict,
  64. Footnote,
  65. Header,
  66. HeaderLeft,
  67. HeaderRight,
  68. HeaderFirst,
  69. Footer,
  70. FooterLeft,
  71. FooterRight,
  72. FooterFirst,
  73. FNSep,
  74. FNContSep,
  75. FNContNotice,
  76. Info,
  77. StyleSheet,
  78. FontTbl,
  79. ColorTbl,
  80. Field,
  81. FieldInst,
  82. FieldResult,
  83. Index,
  84. IndexBold,
  85. IndexItalic,
  86. IndexText,
  87. IndexRange,
  88. TOC,
  89. BookmarkStart,
  90. BookmarkEnd,
  91. ITitle,
  92. ISubject,
  93. IAuthor,
  94. IOperator,
  95. IKeywords,
  96. IComment,
  97. IVersion,
  98. IDoccomm,
  99. MaxDestination,
  100.  
  101. AnsiCharSet,
  102. MacCharSet,
  103. PcCharSet,
  104. PcaCharSet,
  105.  
  106. FFNil,
  107. FFRoman,
  108. FFSwiss,
  109. FFModern,
  110. FFScript,
  111. FFDecor,
  112. FFTech,
  113.  
  114. Red,
  115. Green,
  116. Blue,
  117.  
  118. CurHeadPage,
  119. CurFNote,
  120. CurHeadPict,
  121. CurHeadDate,
  122. CurHeadTime,
  123. Formula,
  124. NoBrkSpace,
  125. NoReqHyphen,
  126. NoBrkHyphen,
  127. Page,
  128. Line,
  129. Par,
  130. Sect,
  131. Tab,
  132. Cell,
  133. Row,
  134. CurAnnot,
  135. Annotation,
  136. AnnotID,
  137. CurAnnotRef,
  138. FNoteSep,
  139. FNoteCont,
  140. Column,
  141. OptDest,
  142. IIntVersion,
  143. ICreateTime,
  144. IRevisionTime,
  145. IPrintTime,
  146. IBackupTime,
  147. IEditTime,
  148. IYear,
  149. IMonth,
  150. IDay,
  151. IHour,
  152. IMinute,
  153. INPages,
  154. INWords,
  155. INChars,
  156. IIntID,
  157.  
  158. BasedOn,
  159. Next,
  160.  
  161. PaperWidth,
  162. PaperHeight,
  163. LeftMargin,
  164. RightMargin,
  165. TopMargin,
  166. BottomMargin,
  167. FacingPage,
  168. GutterWid,
  169. DefTab,
  170. WidowCtrl,
  171. HyphHotZone,
  172. FNoteEndSect,
  173. FNoteEndDoc,
  174. FNoteText,
  175. FNoteBottom,
  176. FNoteStart,
  177. FNoteRestart,
  178. PageStart,
  179. LineStart,
  180. Landscape,
  181. FracWidth,
  182. NextFile,
  183. Template,
  184. MakeBackup,
  185. RTFDefault,
  186. Revisions,
  187. MirrorMargin,
  188. RevDisplay,
  189. RevBar,
  190.  
  191. SectDef,
  192. NoBreak,
  193. ColBreak,
  194. PageBreak,
  195. EvenBreak,
  196. OddBreak,
  197. PageStarts,
  198. PageCont,
  199. PageRestart,
  200. PageDecimal,
  201. PageURoman,
  202. PageLRoman,
  203. PageULetter,
  204. PageLLetter,
  205. PageNumLeft,
  206. PageNumTop,
  207. HeaderY,
  208. FooterY,
  209. LineModulus,
  210. LineDist,
  211. LineStarts,
  212. LineRestart,
  213. LineRestartPg,
  214. LineCont,
  215. TopVAlign,
  216. BottomVAlign,
  217. CenterVAlign,
  218. JustVAlign,
  219. Columns,
  220. ColumnSpace,
  221. ColumnLine,
  222. ENoteHere,
  223. TitleSpecial,
  224.  
  225. CellBordBottom,
  226. CellBordTop,
  227. CellBordLeft,
  228. CellBordRight,
  229. RowDef,
  230. RowLeft,
  231. RowRight,
  232. RowCenter,
  233. RowGapH,
  234. RowHt,
  235. RowLeftEdge,
  236. CellPos,
  237. MergeRngFirst,
  238. MergePrevious,
  239.  
  240. ParDef,
  241. StyleNum,
  242. QuadLeft,
  243. QuadRight,
  244. QuadJust,
  245. QuadCenter,
  246. FirstIndent,
  247. LeftIndent,
  248. RightIndent,
  249. SpaceBefore,
  250. SpaceAfter,
  251. SpaceBetween,
  252. InTable,
  253. Keep,
  254. KeepNext,
  255. SideBySide,
  256. PBBefore,
  257. NoLineNum,
  258. TabPos,
  259. TabRight,
  260. TabCenter,
  261. TabDecimal,
  262. TabBar,
  263. BorderTop,
  264. BorderBottom,
  265. BorderLeft,
  266. BorderRight,
  267. BorderBox,
  268. BorderBar,
  269. BorderBetween,
  270. BorderSingle,
  271. BorderThick,
  272. BorderShadow,
  273. BorderDouble,
  274. BorderDot,
  275. BorderHair,
  276. BorderSpace,
  277. LeaderDot,
  278. LeaderHyphen,
  279. LeaderUnder,
  280. LeaderThick,
  281.  
  282. Plain,
  283. Bold,
  284. Italic,
  285. StrikeThru,
  286. Outline,
  287. Shadow,
  288. SmallCaps,
  289. AllCaps,
  290. Invisible,
  291. FontNum,
  292. FontSize,
  293. Expand,
  294. Underline,
  295. WUnderline,
  296. DUnderline,
  297. DbUnderline,
  298. NoUnderline,
  299. SuperScript,
  300. SubScript,
  301. Revised,
  302. ForeColor,
  303. BackColor,
  304.  
  305. MacQD,
  306. WinMetafile,
  307. WinBitmap,
  308. PicWid,
  309. PicHt,
  310. PicGoalWid,
  311. PicGoalHt,
  312. PicScaleX,
  313. PicScaleY,
  314. PicScaled,
  315. PicCropTop,
  316. PicCropBottom,
  317. PicCropLeft,
  318. PicCropRight,
  319. PixelBits,
  320. BitmapPlanes,
  321. BitmapWid,
  322. PicBinary,
  323.  
  324. FieldDirty,
  325. FieldEdited,
  326. FieldLocked,
  327. FieldPrivate,
  328.  
  329. TOCType,
  330. TOCLevel,
  331.  
  332. PosX,
  333. PosXCenter,
  334. PosXInside,
  335. PosXLeft,
  336. PosXOutSide,
  337. PosXRight,
  338. PosY,
  339. PosYInline,
  340. PosYTop,
  341. PosYCenter,
  342. PosYBottom,
  343. AbsWid,
  344. TextDist,
  345. RPosMargV,
  346. RPosPageV,
  347. RPosMargH,
  348. RPosPageH,
  349. RPosColH
  350. };
  351.  
  352.  
  353. typedef void (*Callback)(void*);
  354.  
  355. void SkipGroup ( void );
  356.  /*
  357.   * parser is here vvvvvvv when function is called.
  358.   *      { ....       ...}
  359.   * skip to here          ^ and return
  360.   */
  361.  
  362. int GetToken ( void );
  363. int CheckCM ( int  , int major );
  364. int CheckCMM ( int  , int major , int minor );
  365. int CheckMM ( int major , int minor );
  366.  
  367. int Class()
  368.   { return rtfClass; };
  369. int Major()
  370.   { return rtfMajor; };
  371. int Minor()
  372.   { return rtfMinor; };
  373. int Param()
  374.   { return rtfParam; };
  375. int TokenLength()
  376.   { return rtfTextLen; };
  377. const char* TokenText()
  378.   { return rtfTextBuf; };
  379.  
  380. protected:
  381.  
  382. RTF();
  383.  
  384. virtual int  next_char() = 0;
  385.  
  386. virtual void pushback(int c) = 0;
  387.  
  388. static int inited;
  389. /*
  390.     RTF buffer size (avoids BUFSIZ, which differs across systems)
  391. */
  392.  
  393. enum{    BufSiz=    1024};
  394.  
  395. char    rtfTextBuf[BufSiz];    /* text of token */
  396. int    rtfTextLen;        /* length of token in rtfTextBuf */
  397. int    rtfClass;        /* token class */
  398. int    rtfMajor;        /* token major number */
  399. int    rtfMinor;        /* token minor number */
  400. int    rtfParam;        /* control symbol parameter */
  401.  
  402. virtual void _GetToken ( void );
  403.  
  404. private:
  405. int  GetChar ( void );
  406. void Lookup (const char*);
  407.  
  408. };
  409.  
  410. #endif
  411.